<!--
 * @Description:  试听-Audition
 * @Author: your name
 * @Date: 2024-06-25
 * @LastEditTime: 2024-06-25
 * @LastEditors: Please set LastEditors
-->

<template>
  <div class="audition heart_w">
    <div class="catename">
      <p
        v-for="(item, index) in AuditionList"
        :key="item.id"
        :class="{ active_p: index == active_audition }"
        @click="AuditionProject(item, index)"
      >
        {{ item.name }}
      </p>
    </div>

    <div class="tryitems">
      <div class="itembox" v-for="item in FreeListCourse" :key="item.id">
        <a href="#" class="images">
          <img :src="item.image" alt="" />
        </a>
        <div class="righttext">
          <h3>{{ item.title }}</h3>
          <p>试听人数：{{ item.free_nums }}</p>
          <div class="btn_shixue">
            <a :href="`#/ShiTingDetail?id=${item.id}`">
              {{ item.button_text }}
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getCateList, getFreeList } from '@/api/audition'
export default {
  name: 'Audition',
  data() {
    return {
      AuditionList: [],
      active_audition: 0,
      cateId: 0,
      FreeListCourse: []
    }
  },
  created() {
    getCateList().then(({ data: data }) => {
      this.AuditionList = data.data
    })
    this.FreeList(this.cateId)
  },
  methods: {
    AuditionProject(it, i) {
      this.active_audition = i
      this.FreeList(it.id)
    },
    FreeList(Id) {
      getFreeList({ page: 1, cate_id: Id }).then(({ data: data }) => {
        this.FreeListCourse = data.data.list
      })
    }
  }
}
</script>

<style scoped lang="scss">
.audition {
  padding: 40px 0;

  .catename {
    display: flex;
    align-items: center;
    justify-content: flex-start;

    .active_p {
      background-color: #e04946;
      color: #fff;
    }

    p:first-child {
      margin-left: 0px;
    }

    p {
      padding: 0 30px;
      height: 40px;
      text-align: center;
      color: #333;
      line-height: 40px;
      border-radius: 5px;
      margin-left: 10px;
      cursor: pointer;
      background-color: #fff;
    }
  }

  .tryitems {
    margin-top: 45px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;

    .itembox {
      width: 525px;
      height: 170px;
      padding: 20px 40px 20px 20px;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      background-color: #fff;
      margin-bottom: 20px;
      box-shadow: 0 0 3px #eaeaea;
      //   box-sizing: border-box;

      .images {
        display: block;
        width: 258px;
        height: 170px;
        text-align: center;

        img {
          width: 100%;
          height: 100%;
        }
      }

      .righttext {
        margin-left: 20px;
        width: 247px;
        height: 170px;
        display: flex;
        flex-direction: column;
        justify-content: space-around;

        h3 {
          font-family: PingFang SC;
          font-weight: 500;
          font-size: 16px;
          color: #111;
          display: block;
          margin-bottom: 7px;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
        }

        p {
          font-weight: 400;
          font-size: 14px;
          color: #999;
        }

        .btn_shixue {
          display: flex;
          flex-direction: row;
          align-items: center;
          margin-top: 12px;
          a {
            padding: 6px 15px;
            border-radius: 13px;
            background: linear-gradient(-90deg, #46c564, #afe46a);
            font-family: PingFang SC;
            font-weight: 500;
            font-size: 11px;
            color: #fff;
          }
        }
      }
    }
  }
}
</style>
